package com.toocms.jinjuhang.ui.mine.succour

import androidx.databinding.ObservableField
import com.blankj.utilcode.util.ActivityUtils
import com.toocms.jinjuhang.config.Constants
import com.toocms.jinjuhang.dialog.options.OptionsDialog
import com.toocms.jinjuhang.dialog.options.OptionsItem
import com.toocms.tab.base.BaseActivity
import com.toocms.tab.base.MultiItemViewModel
import com.toocms.tab.binding.command.BindingAction
import com.toocms.tab.binding.command.BindingCommand

class ApplySuccourParamOptionItemModel(
    viewModel: ApplySuccourModel,
    val type: String,
    val titleObservableField: ObservableField<String>,
    val options: List<out OptionsItem>
) : MultiItemViewModel<ApplySuccourModel>(viewModel) {

    val contentObservableField = ObservableField<String>()


    val itemClickBindingCommand = BindingCommand<BindingAction>(BindingAction {
        OptionsDialog().apply {
            this.title = titleObservableField.get()
            this.optionsItems = options
            this.onOptionClickListener = { option, tag ->
                this@ApplySuccourParamOptionItemModel.contentObservableField.set(
                    option.title().toString()
                )
            }
            show((ActivityUtils.getTopActivity() as BaseActivity).supportFragmentManager,"")
        }
    })

    init {
        itemType = Constants.RecyclerViewItemType.ITEM_TYPE_ONE
    }


}